package service

import (
	"bookkeeping-gin/app/common/request"
	"bookkeeping-gin/app/model"
	"bookkeeping-gin/global"
)

type tagService struct {
}

var TagService = new(tagService)

func (t *tagService) CreateTag(params request.TagForm) (err error, tag *model.Tag) {
	tag = &model.Tag{
		Name:      params.Name,
		Symbol:    params.Symbol,
		Type:      params.Type,
		CreatedBy: params.CreatedBy,
	}
	if err = global.App.DB.Create(tag).Error; err != nil {
		return err, nil
	}
	return nil, tag
}
